package it.davial.mgwt.client.utils;

import java.util.Date;
import java.util.logging.Logger;

import com.google.gwt.i18n.client.DateTimeFormat;

public class SharedUtils {
	
	private static final Logger logger = Logger.getLogger("SharedUtils");

	public static boolean isNullOrEmpty( String value ){
		if ( value == null) return true;
		else 
			return value.isEmpty();
	}
	
	public static Date getFormattedDate( Date date,String pattern ){
		
		DateTimeFormat dtf = DateTimeFormat.getFormat(pattern);
		String s = dtf.format(date);
		logger.info("dateString=" + s);
		return dtf.parse(s);
	}
	
	public static String getFormattedString( Date date,String pattern ){
		
		DateTimeFormat dtf = DateTimeFormat.getFormat(pattern);
		return dtf.format(date);
		
	}
}
